class lustre::server {
  define rmpack {
      exec { "remove_${name}" :
         command => "/bin/rpm -e ${name} --nodeps",
         path => "/bin/rpm",
         onlyif => "/bin/rpm -q  ${name} | /bin/grep -v wc3",
      }
  }
  define rmpackg {
      exec { "remove_${name}" :
         command => "/bin/rpm -e ${name} --nodeps",
         path => "/bin/rpm",
         onlyif => "/bin/rpm -q  ${name} ",
      }
  }
  define pkgforce ($name, $source){
      exec { "force_${name}":
         command => "/bin/rpm -Uvh --force  ${source} --nodeps",
         path => "/bin/rpm",
         unless => "/bin/rpm -q  ${name} ",
      }
  }

  
  rmpackg {"e2fsprogs-libs.i386":}
  rmpackg {"e2fsprogs-libs.x86_64":}
  rmpack {"e2fsprogs":}


  package { 'e2fsprogs':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/e2fsprogs-1.42.3.wc3-0redhat.x86_64.rpm',
    require  => Rmpack['e2fsprogs'],
  }
  package { 'e2fsprogs-devel':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/e2fsprogs-devel-1.42.3.wc3-0redhat.x86_64.rpm',
    require  => Package['lustre'],
  }
  package { 'kernel-debuginfo':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/kernel-debuginfo-2.6.18-308.4.1.el5_lustre.x86_64.rpm',
    require  => Package['kernel-debuginfo-common'],
  }
  package { 'kernel-debuginfo-common':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/kernel-debuginfo-common-2.6.18-308.4.1.el5_lustre.x86_64.rpm',
    require  => Package['lustre'],
  }
  package { 'kernel-headers':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/kernel-headers-2.6.18-308.4.1.el5_lustre.x86_64.rpm',
    require  => Package['lustre'],
  }
  pkgforce { 'kernel-devel-2.6.18-308.4.1.el5_lustre.x86_64':
    name =>  'kernel-devel-2.6.18-308.4.1.el5_lustre.x86_64',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/kernel-devel-2.6.18-308.4.1.el5_lustre.x86_64.rpm',
  #  require  => Package['lustre'],
  }
  package { 'lustre':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/lustre-1.8.8-wc1_2.6.18_308.4.1.el5_lustre.x86_64.rpm',
    require  => Package['lustre-modules'],
  }
  package { 'lustre-ldiskfs':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/lustre-ldiskfs-3.1.52-wc1_2.6.18_308.4.1.el5_lustre.x86_64.rpm',
    require  => Package['lustre'],
  }
  package { 'lustre-modules':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://mirror.ihep.ac.cn/quattor/lustre/lustre-modules-1.8.8-wc1_2.6.18_308.4.1.el5_lustre.x86_64.rpm',
    require  => Package['e2fsprogs'],
  }
  package { 'lustre-debuginfo':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://202.122.33.67/quattor/lustre/lustre-debuginfo-1.8.8-wc1_2.6.18_308.4.1.el5_lustre.x86_64.rpm',
    require  => Package['lustre'],
  }
  package { 'lustre-ldiskfs-debuginfo':
    provider => 'rpm',
    ensure   => 'installed',
    source   => 'http://202.122.33.67/quattor/lustre/lustre-ldiskfs-debuginfo-3.1.52-wc1_2.6.18_308.4.1.el5_lustre.x86_64.rpm',
    require  => Package['lustre-ldiskfs'],
  }
  package { 'yum-versionlock.noarch':
    ensure   => 'installed',
  }
  package { 'systemtap':
    ensure   => 'installed',
  }
  package { 'vnc-server':
    ensure   => 'installed',
  }

  # disable e2fsprogs auto update
  $yumversionlock="e2fsprogs
   e2fsprogs-devel
   "
  file { "/etc/yum/pluginconf.d/versionlock.list":
   content => "$yumversionlock",
   require => Package['yum-versionlock.noarch'],
  }
}
